package com.example.q_kang.hhh.home;


import android.content.Context;
import android.content.Intent;
import android.media.audiofx.Visualizer;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.example.q_kang.hhh.R;
import com.hjq.toast.ToastUtils;
import com.sskj.base.MVPActivity;
import com.sskj.base.base.App;
import com.sskj.base.utils.ClickUtil;
import com.sskj.base.view.ToolBarLayout;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @author Hey
 * Create at  2019/04/10
 */
public class CodeJiHuoSendActivity extends MVPActivity<CodeJiHuoSendPresenter> {

    @BindView(R.id.toolbar)
    ToolBarLayout toolbar;
    @BindView(R.id.tv_money)
    TextView tvMoney;
    @BindView(R.id.et_mobile)
    EditText etMobile;
    @BindView(R.id.et_amount)
    EditText etAmount;
    @BindView(R.id.btn_submit)
    Button btnSubmit;
    private int myJiHuo;

    @Override
    public int getLayoutId() {
        return R.layout.activity_code_j_ih_uosend;
    }

    @Override
    public CodeJiHuoSendPresenter getPresenter() {
        return new CodeJiHuoSendPresenter();
    }

    @Override
    public void initView() {
        toolbar.setLeftButtonOnClickListener(view -> finish());
        toolbar.setRightButtonOnClickListener(view -> SendRecordActivity.start(this, App.INSTANCE.getString(R.string.appJavaCodeJiHuoSendActivity1)));
        myJiHuo = getIntent().getIntExtra("myJiHuo", -1);
        tvMoney.setText(String.valueOf(myJiHuo));
        ClickUtil.click(300, btnSubmit, view -> {
            if (TextUtils.isEmpty(getEtext(etMobile))) {
                ToastUtils.show(App.INSTANCE.getString(R.string.appJavaCodeJiHuoSendActivity3));
                return;
            }
            if (TextUtils.isEmpty(getEtext(etAmount))) {
                ToastUtils.show(App.INSTANCE.getString(R.string.appJavaCodeJiHuoSendActivity4));
                return;
            }
            mPresenter.sendJiHuo(getEtext(etMobile), getEtext(etAmount));
        });
    }

    @Override
    public void initData() {
        mPresenter.getJiHuo();
    }

    public static void start(Context context, int myJiHuo) {
        Intent intent = new Intent(context, CodeJiHuoSendActivity.class);
        intent.putExtra("myJiHuo", myJiHuo);
        context.startActivity(intent);
    }
}
